<template>
  <div>
    <canvas id="canvas"></canvas>
  </div>
</template>

<script>
import QRCode from "qrcode";
import axios from "axios";
export default {
  name: "QRCode",
  mounted() {
    this.getQr();
  },
  methods: {
    getQr() {
      axios("http://localhost:3000/qrcode").then((res) => {
        console.log(res, "res");
        const canvas = document.getElementById("canvas");
        QRCode.toCanvas(canvas, res.data.qrcode, function (error) {
          if (error) console.error(error);
          console.log("success!");
        });
      });
    },
  },
};
</script>
